# -*- coding: utf-8 -*-
"""
author:码同学 极光
date:2024/3/24
desc: 
sample: 
"""
import random


class Class():
    def __init__(self,name):
        self.students = set()
        self.name = name

    def add_student(self,student):
        self.students.add(student)

    @property
    def query_student(self):
        #去重支持
        unique_student_set = set((item.name, item.score) for item in self.students)
        for student in unique_student_set:
            print(student)

class Students():
    def __init__(self,name,score,clz) -> None:
        self.name = name
        self.score = score
        self.clz = clz
        self.clz.add_student(self)


    def __str__(self) -> str:
        return f'{self.name}:{self.score}'


clz1= Class('班级1')
clz2= Class('班级2')

Students('zhangsan1',random.randint(50,100),clz1)
Students('zhangsan2',60,clz1)
Students('zhangsan2',60,clz1)
Students('zhangsan3',random.randint(50,100),clz2)
Students('zhangsan4',random.randint(50,100),clz2)
Students('zhangsan5',random.randint(50,100),clz2)

print("班级1")
students = clz1.query_student
print("班级2")
print(clz2.query_student)
